#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
@author:jidi
@file:session_http_api.py
@time:2022/08/14
"""
import requests

from service.wework.model.calendar_app import CalendarApp
from service.wework.model.session import Session
from service.wework.model.wework import WeWork
from service.wework.utils.log import log


class SessionHttpApi(Session):
    def refresh_token(self, wework: WeWork, app: CalendarApp):
        r = requests.get(
            'https://qyapi.weixin.qq.com/cgi-bin/gettoken',
            params={
                'corpid': wework.corpid,
                'corpsecret': app.secret
            }
        )
        log.debug(r.json())
        return r.json()['access_token']
